using System;
using System.Collections;
using System.IO;
using System.Text;
public class EventLocalUtil1
{
	public static string pid = "";
	public static bool smethod_0(string string_1, string string_2)
	{
		bool result;
		try
		{
			string path = EventLocalUtil1.smethod_7() + "\\" + string_1;
			if (File.Exists(path))
			{
				File.Delete(path);
			}
			FileStream fileStream = new FileStream(path, FileMode.Create);
			StreamWriter streamWriter = new StreamWriter(fileStream, Encoding.GetEncoding("GB2312"));
			streamWriter.Write(string_2);
			streamWriter.Flush();
			streamWriter.Close();
			streamWriter.Dispose();
			fileStream.Close();
			fileStream.Dispose();
			result = true;
		}
		catch
		{
			result = false;
		}
		return result;
	}
	public static EventGoodsItem smethod_1(string string_1, string string_2)
	{
		string text = EventLocalUtil1.read_eventBean(string_1);
		if ("".Equals(text))
		{
			return null;
		}
		return EventLocalUtil1.read_Event_goods(string_1, string_2, text);
	}
	public static EventGoodsItem read_Event_goods(string event_id, string num_iid, string content)
	{
		new ArrayList();
		int num = 0;
		while ((num = content.IndexOf("\"itemId\":", num)) != -1)
		{
			string text = StringUtil.subString(content, num, "\"itemId\":", ",");
			if (num_iid.Equals(text))
			{
				return new EventGoodsItem
				{
					event_id = event_id,
					num_iid = text,
					url = "http:" + StringUtil.subString(content, num, "\"href\":\"", "\","),
					string_3 = "",
					pic_url = "http:" + StringUtil.subString(content, num, "\"picUrl\":\"", "\",")
				};
			}
			num++;
		}
		return null;
	}
	public static void smethod_3(string string_1)
	{
		string path = EventLocalUtil1.smethod_7() + "\\" + string_1;
		if (File.Exists(path))
		{
			File.Delete(path);
		}
	}
	public static EventGoods smethod_4(string string_1, string string_2)
	{
		string text = EventLocalUtil1.read_eventBean(string_1);
		if ("".Equals(text))
		{
			return null;
		}
		return EventLocalUtil1.smethod_5(string_1, string_2, text);
	}
	public static EventGoods smethod_5(string event_id, string num_iid, string content)
	{
		new ArrayList();
		int num = 0;
		while ((num = content.IndexOf("\"itemId\":", num)) != -1)
		{
			string text = StringUtil.subString(content, num, "\"itemId\":", ",");
			if (num_iid.Equals(text))
			{
				EventGoods eventGoods = new EventGoods();
				eventGoods.event_id = event_id;
				eventGoods.num_iid = text;
				eventGoods.title = StringUtil.subString(content, num, "\"itemTitle\":\"", ",\"");
				eventGoods.url = "http:" + StringUtil.subString(content, num, "\"href\":\"", "\",");
				eventGoods.user_num_id = StringUtil.subString(content, num, "\"sellerId\":", ",");
				eventGoods.pic_url = "http:" + StringUtil.subString(content, num, "\"picUrl\":\"", "\",");
				eventGoods.commission_rate = double.Parse(StringUtil.subString(content, num, "\"commissionRate\":", ",")) / 100.0;
				eventGoods.is_sold_out = (bool.Parse(StringUtil.subString(content, num, "\"isSoldOut\":", ",")) ? 1 : 0);
				eventGoods.price = double.Parse(StringUtil.subString(content, num, "\"discountPrice\":\"", "\","));
				eventGoods.ori_price = StringUtil.subString(content, num, "\"auctionPrice\":\"", "\",");
				eventGoods.discount_rate = StringUtil.subString(content, num, "\"discountRate\":\"", "\",");
				if (eventGoods.discount_rate.Equals(""))
				{
					eventGoods.discount_rate = "0";
				}
				eventGoods.volume = int.Parse(StringUtil.subString(content, num, "\"soldQuantity\":", ","));
				eventGoods.is_mall = (bool.Parse(StringUtil.subString(content, num, "\"mall\":", "}")) ? 1 : 0);
				return eventGoods;
			}
			num++;
		}
		return null;
	}
	public static string read_eventBean(string event_id)
	{
		string path = EventLocalUtil1.smethod_7() + "\\" + event_id;
		if (!File.Exists(path))
		{
			return "";
		}
		StreamReader streamReader = new StreamReader(path, Encoding.GetEncoding("GB2312"));
		string result = streamReader.ReadToEnd();
		streamReader.Close();
		streamReader.Dispose();
		return result;
	}
	public static string smethod_7()
	{
		string currentDirectory = Directory.GetCurrentDirectory();
		string text = currentDirectory + "\\config\\鹊桥数据\\" + EventLocalUtil1.pid;
		if (!Directory.Exists(text))
		{
			Directory.CreateDirectory(text);
		}
		EventLocalUtil1.smethod_8(currentDirectory + "\\config\\鹊桥数据", text);
		return text;
	}
	public static void smethod_8(string string_1, string string_2)
	{
		string[] files = Directory.GetFiles(string_1);
		for (int i = 0; i < files.Length; i++)
		{
			string text = files[i];
			File.Move(text, string_2 + "\\" + text.Substring(text.LastIndexOf("\\") + 1));
		}
	}
}
